package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HaSchedules;
import com.ruoyi.system.service.IHaSchedulesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 排班列表Controller
 * 
 * @author 鲍小伟
 * @date 2025-11-17
 */
@RestController
@RequestMapping("/system/schedules")
public class HaSchedulesController extends BaseController
{
    @Autowired
    private IHaSchedulesService haSchedulesService;

    /**
     * 查询排班列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:schedules:list')")
    @GetMapping("/list")
    public TableDataInfo list(HaSchedules haSchedules)
    {
        startPage();
        List<HaSchedules> list = haSchedulesService.selectHaSchedulesList(haSchedules);
        return getDataTable(list);
    }

    /**
     * 导出排班列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:schedules:export')")
    @Log(title = "排班列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HaSchedules haSchedules)
    {
        List<HaSchedules> list = haSchedulesService.selectHaSchedulesList(haSchedules);
        ExcelUtil<HaSchedules> util = new ExcelUtil<HaSchedules>(HaSchedules.class);
        util.exportExcel(response, list, "排班列表数据");
    }

    /**
     * 获取排班列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:schedules:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(haSchedulesService.selectHaSchedulesById(id));
    }

    /**
     * 新增排班列表
     */
    @PreAuthorize("@ss.hasPermi('system:schedules:add')")
    @Log(title = "排班列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HaSchedules haSchedules)
    {
        return toAjax(haSchedulesService.insertHaSchedules(haSchedules));
    }

    /**
     * 修改排班列表
     */
    @PreAuthorize("@ss.hasPermi('system:schedules:edit')")
    @Log(title = "排班列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HaSchedules haSchedules)
    {
        return toAjax(haSchedulesService.updateHaSchedules(haSchedules));
    }

    /**
     * 删除排班列表
     */
    @PreAuthorize("@ss.hasPermi('system:schedules:remove')")
    @Log(title = "排班列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(haSchedulesService.deleteHaSchedulesByIds(ids));
    }
}
